package com.sdhs.costcontrol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.costcontrol.domain.GcControlPlanList;
import com.sdhs.costcontrol.service.IGcControlPlanListService;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 采购计划-子-清单Controller
 *
 * @author andong
 * @date 2025-03-14
 */
@RestController
@RequestMapping("/costcontrol/planList")
public class GcControlPlanListController extends BaseController
{
    @Autowired
    private IGcControlPlanListService gcControlPlanListService;

    /**
     * 查询采购计划-子-清单列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:planList:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcControlPlanList gcControlPlanList)
    {
        startPage();
        List<GcControlPlanList> list = gcControlPlanListService.selectGcControlPlanListList(gcControlPlanList);
        return getDataTable(list);
    }

    /**
     * 导出采购计划-子-清单列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:planList:export')")
    @Log(title = "采购计划-子-清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcControlPlanList gcControlPlanList)
    {
        List<GcControlPlanList> list = gcControlPlanListService.selectGcControlPlanListList(gcControlPlanList);
        ExcelUtil<GcControlPlanList> util = new ExcelUtil<GcControlPlanList>(GcControlPlanList.class);
        util.exportExcel(response, list, "采购计划-子-清单数据");
    }

    /**
     * 获取采购计划-子-清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:planList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcControlPlanListService.selectGcControlPlanListById(id));
    }

    /**
     * 新增采购计划-子-清单
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:planList:add')")
    @Log(title = "采购计划-子-清单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcControlPlanList gcControlPlanList)
    {
        return toAjax(gcControlPlanListService.insertGcControlPlanList(gcControlPlanList));
    }

    /**
     * 修改采购计划-子-清单
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:planList:edit')")
    @Log(title = "采购计划-子-清单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcControlPlanList gcControlPlanList)
    {
        return toAjax(gcControlPlanListService.updateGcControlPlanList(gcControlPlanList));
    }

    /**
     * 删除采购计划-子-清单
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:planList:remove')")
    @Log(title = "采购计划-子-清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcControlPlanListService.deleteGcControlPlanListByIds(ids));
    }
}
